<?php
/**
 * Created by PhpStorm.
 * User: yzl
 * Date: 17/5/25
 * Time: 下午7:00
 */

namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
        //$json = $GLOBALS['HTTP_RAW_POST_DATA'];
        $json = @file_get_contents('php://input', 'r');
        $jsonInfo = (array)json_decode($json);

        //获取用户名和密码
        $user     = $jsonInfo['user'];
        $password = $jsonInfo['password'];

        //验证密码
        $passw = M('rater')->field('passw',false)->where("rater_no = '$user'")->select();
        $passw = $passw[0]['passw'];

        //验证密码正确与否
        if($password == $passw){
            echo json_encode(array('status'=>0,'user'=>"$user",'password'=>"$password"));
        }else{
            echo json_encode(array('status'=>1,'data'=>'用户名密码错误'));
        }

    }
}